<header class="page-header clearfix">
    <h4><a ui-sref="app-service"><i class="fa fa-arrow-left"></i></a>应用 {{::dtl.appCode}}</h4>
    <div class="toolbox">
        <a type="button" permission="perm_service_add" ui-sref="app-service-version-publish.deploy({appId: dtl.id, k8sCode: dtl.k8sCode,lesseeCode:dtl.namespace})"><i class="fa fa-plus"></i>添加服务</a>
    </div>
    <ol class="breadcrumb">
        <li><a>我的应用</a></li>
        <li><a ui-sref="app-service">应用管理</a></li>
        <li class="active">应用详情</li>
    </ol>
</header>
<section>
        <div class="panel">
            <div class="panel-heading">详情</div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-3">
                        <dt>名称</dt>
                        <dd>{{::dtl.appName}}</dd>
                    </div>
                    <div class="col-md-3">
                        <dt>编码</dt>
                        <dd>{{::dtl.appCode}}</dd>
                    </div>
                    <div class="col-md-3">
                        <dt>所在集群</dt>
                        <dd><a ui-sref="k8s-overview({kDbCode: dtl.k8sCode})">{{::dtl.k8sCode}}</a></dd>
                    </div>
                    <div class="col-md-3">
                        <dt>所在租户</dt>
                        <dd><a ui-sref="k8s-lessee({kDbCode: dtl.k8sCode})">{{::dtl.namespace}}</a></dd>
                    </div>
                </div>
                <dt ng-switch="dtl.edition">简介
                    <a ng-switch-when="false" href="javascript: void(0)" ng-click="dtl.editDetail()"
                       class="margin-left-5"><i class="fa fa-pencil"></i></a>
                    <a ng-switch-when="true" href="javascript: void(0)" ng-click="dtl.saveEdit()"
                       class="margin-left-5 text-success"><i class="fa fa-check"></i></a>
                    <a ng-switch-when="true" href="javascript: void(0)" ng-click="dtl.cancelEdit()"
                       class="margin-left-5 text-danger"><i class="fa fa-times"></i></a>
                    <span ng-switch-when="loading" class="margin-left-5"><i class="fa fa-refresh fa-spin fa-fw"></i></span>
                </dt>
                <dd ng-switch="dtl.edition">
                    <span ng-switch-when="false">{{::dtl.content || '-'}}</span>
                    <textarea ng-model="dtl.content_edit" style="resize: none" class="form-control" ng-switch-default/>
                </dd>
            </div>
        </div>
    </div>
    <h5>服务列表</h5>
    <div class="panel panel-list service-detail-panel" ng-style="::ser.border" ng-repeat="ser in dtl.serviceList">
        <div class="panel-body">
            <div class="form-search clearfix">
                <strong ng-style="::ser.color">{{::ser.dpName}}</strong>
                <span ng-switch="ser.releaseState">
                    <span class="label label-primary" ng-switch-when="001"><i class="margin-right-5 fa fa-cog fa-spin"/>发布中</span>
                    <span ng-switch-when="002" ng-switch="ser.state">
                        <span class="label label-success" ng-switch-when="001">启用</span>
                        <span class="label label-danger" ng-switch-when="002">停用</span>
                    </span>
                    <span class="label label-danger" ng-switch-when="003"><i class="margin-right-5 fa fa-times"/>发布失败</span>
                </span>
                <div ng-if="!ser.loading" class="pull-right">
                    <button ng-click="ser.newRs=null;ser.oldTable=null;dtl.checkState(ser)" class="btn btn-default btn-sm" permission="perm_service_refresh">刷新</button>
                    <button ng-if="ser.state == '001' && ser.releaseState == '002'" ng-click="dtl.stopService(ser)" permission="perm_service_stop" class="btn btn-default btn-sm">停用</button>
                    <button ng-if="ser.state == '002' && ser.releaseState == '002'" ng-click="dtl.startService(ser)" permission="perm_service_start" class="btn btn-default btn-sm">启用</button>
                    <button ng-click="dtl.deleteService(ser)" class="btn btn-default btn-sm" permission="perm_service_delete">移除</button>
                    <span uib-dropdown>
                        <button class="btn btn-default btn-sm" uib-dropdown-toggle>更多</button>
                        <ul class="dropdown-menu animate fade-in-down">
                            <li ng-if="ser.releaseState != '001'" permission="perm_service_update">
                                <a ui-sref="app-service-version-publish.deploy({appId: dtl.id, k8sCode: ser.k8sCode,serId:ser.serviceId,lesseeCode:ser.namespace})">
                                    <i class="fa fa-wrench" ></i><span >更新</span></a></li>
                            <li ng-if="ser.oldTable.length"  permission="perm_service_rollback">
                                <a ng-click="dtl.openRollForm(ser)"><i class="fa fa-undo"></i><span >回滚</span></a></li>
                            <li ng-if="ser.releaseState == '002'"  permission="perm_service_scale">
                                <a ng-click="dtl.openReplicasForm(ser)"><i class="fa fa-plus"></i><span   >手动伸缩</span></a></li>
                            <li ng-if="ser.releaseState == '002'"  permission="perm_service_advance">
                                <a ng-click="dtl.openAdvanceForm(ser)"><i class="fa fa-bolt fa-lg"></i><span >高级配置</span></a></li>
                            <li>
                                <a ng-click="dtl.openLogForm(ser)"><i class="fa fa-file-text"></i><span >查看Yaml</span></a></li>
                        </ul>
                    </span>
                </div>
                <div ng-if="ser.loading" class="pull-right">
                    <div class="loading"></div>
                </div>
            </div>
            <service-table></service-table>
            <div class="text-danger" ng-if="ser.releaseState == '003'">
                <i class="fa fa-exclamation-circle margin-right-10"></i>{{::ser.releaseStateDescription}}
            </div>
        </div>
    </div>
    <div class="loading" style="margin: 0 auto" ng-show="!dtl.serviceList"></div>
    <div ng-show="dtl.serviceList" class="pagination-group margin-bottom-20">
        <ui-pagination-info items-per-page="5" items-per-page-select="false"
                            total-items="dtl.page.totalItems"
                            current-page="dtl.page.currentPage"></ui-pagination-info>
        <button type="button" ng-click="dtl.getList()" class="btn btn-default btn-refresh"><i class="fa fa-refresh"></i></button>
        <ui-pagination items-per-page="5" total-items="dtl.page.totalItems"
                       ng-model="dtl.page.currentPage" ng-change="dtl.getList()"></ui-pagination>
    </div>
</section>
